// src/services/translationService.js
import axios from 'axios';
 
const translate = async (text, targetLanguage) => {
    const url = `https://translation.googleapis.com/language/translate/v2`;
    const params = {
        q: text,
        target: targetLanguage,
        format: 'text',
        key: 'AIzaSyCI2pwryEgbI08z-xkDrUZ93UuLX9wGnG4'
    };
 
    try {
        console.log(1)
        const response = await axios.get(url, { params });
        return response.data.data.translations[0].translatedText;
    } catch (error) {
        console.log(2)
        console.error('Translation error:', error);
        return null;
    }
};
 
export default { translate };